from sqlalchemy.ext.asyncio import AsyncSession as Session
from app.models.waveup.wp_user import WpUser
from app.schemas.waveup.wp_user import WpUserCreate
from sqlalchemy import select

async def create_wp_user(session: Session, wp_user: WpUserCreate) -> WpUser:
    """创建Waveup用户"""
    db_wp_user = WpUser.model_validate(wp_user)
    session.add(db_wp_user)
    await session.commit()
    await session.refresh(db_wp_user)
    return db_wp_user

async def get_wp_user_by_uid(session: Session, uid: int) -> WpUser:
    """根据用户ID查询Waveup用户"""
    statement = select(WpUser).where(WpUser.uid == uid)
    result = await session.execute(statement)
    return result.scalar_one_or_none()